# schemas/transcript.py
from typing import Union
from datetime import datetime
from pydantic import Field
from fastapi import Query

from admin.schemas.base import CamelModel


class MeetingsTranscriptsListIn(CamelModel):
    meeting_id: Union[int, None] = Field(default=None)
    recording_id: Union[int, None] = Field(default=None)

    class Config:
        from_attributes = True
        field_operator_mapping = {
            "meeting_id": "=",
            "recording_id": "=",
        }


class MeetingsTranscriptsDetailIn(CamelModel):
    id: int = Query(..., gt=0)


class MeetingsTranscriptsAddIn(CamelModel):
    meeting_id: int
    recording_id: Union[int, None] = None
    start_ts_ms: int
    end_ts_ms: int
    speaker: Union[str, None] = None
    text: str


class MeetingsTranscriptsEditIn(MeetingsTranscriptsAddIn):
    id: int = Field(..., gt=0)


class MeetingsTranscriptsDelIn(CamelModel):
    id: int = Field(..., gt=0)


class MeetingsTranscriptsOut(CamelModel):
    id: int
    meeting_id: int
    recording_id: Union[int, None]
    start_ts_ms: int
    end_ts_ms: int
    speaker: Union[str, None]
    text: str
    created_at: Union[datetime, None]

    class Config:
        from_attributes = True
